﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Middle_537_ComplexNumberMultiply
{
    class MainProject
    {
        static void Main(string[] args)
        {
            Console.WriteLine(ComplexNumberMultiply("1+-1i", "1+-1i"));
            Console.ReadKey();
        }
        public static string ComplexNumberMultiply(string num1, string num2)
        {
            string[] n1 = num1.Split('+');
            string[] n2 = num2.Split('+');

            Queue<string> que = new Queue<string>();

            int iNum1 = int.Parse(n1[0]);
            int iNum2 = int.Parse(n2[0]);

            int iNum3 = int.Parse(ReduceI(n1[1]));
            int iNum4 = int.Parse(ReduceI(n2[1]));

            int realPart = iNum1 * iNum2 - (iNum3 * iNum4);

            int iNum5 = int.Parse(n1[0]);
            int iNum6 = int.Parse(ReduceI(n2[1]));

            int iNum7 = int.Parse(ReduceI(n1[1]));
            int iNum8 = int.Parse(n2[0]);

            int imaginaryPart = iNum5 * iNum6 + iNum7 * iNum8;

            string str = realPart.ToString() +"+"+ imaginaryPart.ToString() + "i";
            return str;

        }

        public static string ReduceI(string str)
        {
            return str.Substring(0, str.Length - 1);
        }

    }
}
